$(document).ajaxError(function (event,xhr,options,exc) {
   if (xhr.status==401){
       location.href="blog_login.html";
   }
});

$(document).ajaxSend(function (event,xhr,options) {
    let userToken=localStorage.getItem("token");
    xhr.setRequestHeader("user_token",userToken);
});

function getUserInfo(url){
    $.ajax({
        type: "get",
        url: url,
        success: function (result){
            if (result!=null&&result.code==200&&result.data!=null){
                let userInfo=result.data;
                $(".left .card h3").text(userInfo.userName);
                $(".left .card a").attr("href",userInfo.githubUrl);
            }
        }
    });
}

function logout(){
    localStorage.removeItem("loginUserId");
    localStorage.removeItem("token");
    location.href="blog_login.html";
}